package cn.itsource.user.controller;

import cn.itsource.basic.util.AjaxResult;
import cn.itsource.user.service.ICodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/code")
public class CodeCotroller {

    @Autowired
    private ICodeService codeService;

    //{"phone":"11","type":"register"}
    @PostMapping("/sendCode")
    public AjaxResult sendCode(@RequestBody Map<String ,String> map){
        try {
            codeService.sendCode(map);
            return AjaxResult.me();
        } catch (Exception e) {
            e.printStackTrace();

            return AjaxResult.me().setMessage(e.getMessage());
        }



    }
}
